#
# $Id: Makefile,v 1.1.1.1 1995/03/13 18:25:51 chris Exp $
#

CC = gcc
AR = ar
CFLAGS = -O2 -m486 -ansi -D_GNU_SOURCE -I../include
#CFLAGS = -g -I../include
# YACC = yacc
YACC = bison -y
# LEX = lex
LEX = flex -l -p

OBJS = atom.o
LIBS = libdtd.a

all: $(LIBS)

# create library

libdtd.a: dtd.o atom.o
	$(AR) rcv $@ dtd.o atom.o
	ranlib libdtd.a

dtd.o: dtddefs.h dtdtab.h

dtddefs.h: html.1 dtd2
	dtd2 < html.1

dtdtab.h: html.1 dtd2
	dtd2 < html.1

# create parser

dtd2: y.tab.o lex.yy.o $(OBJS)
	$(CC) y.tab.o lex.yy.o $(OBJS) -ll -o $@

y.tab.c: dtd2.y
	$(YACC) -v -d dtd2.y

lex.yy.c: y.tab.h dtd2.l
	$(LEX) dtd2.l

y.tab.h: y.tab.c

# create dtd1 to make first pass over dtd.html

html.1: html.dtd dtd1/dtd1
	dtd1/dtd1 < html.dtd > $@

dtd1/dtd1:
	(cd dtd1; make dtd1)

clean:;	(cd dtd1; make clean)
	@rm -f core *.o lex.yy.c y.tab.h y.tab.c y.output make.out $(LIBS) dtddefs.h dtdtab.h dtd2 html.1
